package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author liyang
 * @version 1.0
 * @package reflect
 * @file ReflectDemo3.java
 * @description
 * @time 2024/6/23 下午6:45
 */
public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        /*获取有参构造器*/
        Class cls = Class.forName("reflect.Person");
        Constructor c = cls.getConstructor(String.class,int.class);
        Object obj = c.newInstance("王五",24);
        System.out.println(obj);
    }
}
